
package trim.differentmaterials.resttrimmer;

import trim.differentmaterials.core.*;
import trim.differentmaterials.generator.core.*;
import trim.differentmaterials.generator.columns.*;

/**
 *
 * @author Podorov Alexander
 */

public class ExactRequiresRestTrimmer extends RestTrimmer
{
    public ExactRequiresRestTrimmer(TrimCore core, Generator generator)
    {
        super(core, generator);
    }
   
    protected void restsToPatterns()
    {
        while (isFormatRests())
        {
            Column pattern = generator.getResidualPattern(false);

            int[] items = pattern.getItems();
            for (int i = 0; i < formatCount; i++)
            {
                formatRests[i] -= items[i];
            }
            ((RealPattern)pattern).setCount(1);
            patterns.add(pattern);
        }
    }

    public void start()
    {
        setFormatRests();
        restsToPatterns();
    }
}
